package com.spec.controller.system;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.spec.config.Const;
import com.spec.services.system.log.ILogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import sys.basic.controller.BaseController;
import sys.basic.entity.PageData;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by hzq on 2017/5/30.
 */
@Controller
@RequestMapping(value = "/log")
public class LogController extends BaseController {
    @Resource(name = "logService")
    private ILogService logService;
    /**
     *
     * @return
     */
    @RequestMapping("/list")
    public ModelAndView list(){
        ModelAndView mv = this.getModelAndView();
        PageData pd = this.getPageData();
        PageInfo<PageData> logs   = null;
        try {
            PageHelper.startPage(Integer.parseInt(pd.getString("page")), Const.PAGE_NUMBER);
            List<PageData> res = logService.list(pd);
            logs= new PageInfo<PageData>(res);
        } catch (Exception e) {
            e.printStackTrace();
        }
        mv.addObject("log",logs.getList());
        mv.addObject("pd",pd);
        mv.setViewName("system/log/log_list");
        return  mv;
    }

}
